Next: , Previous: Programming Answer 1, Up: Answers to Exercises


3.7.59 Programming Tutorial Exercise 2

One way is to move the number to the top of the stack, operate on it, then move it back: C-x ( M-<TAB> n M-<TAB> M-<TAB> C-x ).

Another way is to negate the top three stack entries, then negate again the top two stack entries: C-x ( M-3 n M-2 n C-x ).

Finally, it turns out that a negative prefix argument causes a command like n to operate on the specified stack entry only, which is just what we want: C-x ( M-- 3 n C-x ).

Just for kicks, let's also do it algebraically: C-x ( ' -$$$, $$, $ <RET> C-x ).